package com.ruoyi.merchant.task;

import com.ruoyi.merchant.service.IAutoAcceptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 自动接单定时任务
 */
@Component
public class AutoAcceptTask {

    private static final Logger log = LoggerFactory.getLogger(AutoAcceptTask.class);

    @Autowired
    private IAutoAcceptService autoAcceptService;

    /**
     * 自动接单任务
     * 每30秒执行一次
     */
    @Scheduled(fixedDelay = 30000, initialDelay = 10000)
    public void autoAcceptOrders() {
        log.debug("触发自动接单定时任务");
        try {
            autoAcceptService.executeAutoAccept();
        } catch (Exception e) {
            log.error("自动接单定时任务执行失败", e);
        }
    }
}
